package mviewer.types;

public class Material {

	private String  name;
	private IVector ambientColor	= new VectorData(0.3f, 0.3f, 0.3f);
	private IVector diffuseColor	= new VectorData(0.5f, 0.5f, 0.5f);
	private IVector specularColor	= new VectorData(1f, 1f, 1f);
	private float	shininess		= 50f;
	private float	opacity			= 1f;
	private boolean smooth			= true;
	private String	textureFile;

	public Material() {
		name = "default";
	}

	public Material(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public IVector getAmbientColor() {
		return ambientColor;
	}

	public void setAmbientColor(IVector ambientColor) {
		if (ambientColor == null)
			throw new IllegalArgumentException("ambientColor cannot be null");
		this.ambientColor = ambientColor;
	}

	public IVector getDiffuseColor() {
		return diffuseColor;
	}

	public void setDiffuseColor(IVector diffuseColor) {
		if (diffuseColor == null)
			throw new IllegalArgumentException("diffuseColor cannot be null");
		this.diffuseColor = diffuseColor;
	}

	public IVector getSpecularColor() {
		return specularColor;
	}

	public void setSpecularColor(IVector specularColor) {
		if (specularColor == null)
			throw new IllegalArgumentException("specularColor cannot be null");
		this.specularColor = specularColor;
	}

	public float getShininess() {
		return shininess;
	}

	public void setShininess(float shininess) {
		if (shininess < 0 || shininess > 1000)
			throw new IllegalArgumentException("Shininess has to be in range 0..1000. Given: " + shininess);
		this.shininess = shininess;
	}

	public float getOpacity() {
		return opacity;
	}

	public void setOpacity(float opacity) {
		this.opacity = opacity;
	}

	public boolean isSmooth() {
		return smooth;
	}

	public void setSmooth(boolean smooth) {
		this.smooth = smooth;
	}

	public String getTextureFile() {
		return textureFile;
	}

	public void setTextureFile(String textureFile) {
		this.textureFile = textureFile;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Material other = (Material) obj;
		if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		int hash = 5;
		hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
		return hash;
	}

	@Override
	public String toString() {
		return name;
	}

}
